package cn.itsource.basic.listener;

import cn.itsource.basic.service.IPermissionScanService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
@Slf4j
public class MyListener implements ServletContextListener {

    @Autowired
    private IPermissionScanService permissionScanService;
    @Override
    public void contextInitialized(ServletContextEvent sce) {

        //异步线程
        new Thread(new Runnable() {
            @Override
            public void run() {
                log.info("权限初始化开始******************************************");
                System.out.println("权限初始化开始******************************************");
                permissionScanService.scanPermission();
                System.out.println("权限初始化结束******************************************");
            }
        }).start();
    }
}
